package com.zr.Inquiry.mapper;

import com.zr.Inquiry.pojo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * Created by Administrator on 2019/9/21.
 */
@Mapper
public interface InquiryMapper {

    int queryCount(InquirySelectVo inquirySelectVo);

    List<InquiryVo> queryData(InquirySelectVo inquirySelectVo);

    @Select("select * from supplier s  left join legalperson_supplier ls on s.id=ls.supplierId where ls.personId=#{legalPersonId} ")
    List<InquiryVo> queryByLegalPerson(InquiryVo inquiryVo);

    List<InquirySpareVo> queryDataBySpare(SpareSelectVo spareSelectVo);

    int queryCountBySpare(SpareSelectVo spareSelectVo);

    List<InquirySupplierVo> queryDataBySupplier(SupplierSelectVo supplierSelectVo);

    int queryCountBySupplier(SupplierSelectVo supplierSelectVo);

    @Select("select * from inquirytotal i " +
            "LEFT JOIN inquirysparedetail isd on i.id=isd.inquiryId " +
            "LEFT JOIN inquirysupplierdetail ipd on i.id=ipd.inquiryId " +
            "LEFT JOIN legalperson lp on lp.id=i.legalPersonId ")
    InquiryVo queryByInquirytotal(InquirySelectVo inquirySelectVo);

    @Select("select isd.* from inquirysparedetail isd " +
            "LEFT JOIN inquirytotal i on i.id=isd.inquiryId " +
            "LEFT JOIN inquirysupplierdetail ipd on i.id=ipd.inquiryId  " +
            "LEFT JOIN legalperson lp on lp.id=i.legalPersonId")
    List<Inquirysparedetail> queryByInquirysparedetail(InquirySelectVo inquirySelectVo);

    @Select("select ipd.* from inquirysupplierdetail ipd  " +
            "LEFT JOIN  inquirytotal i on i.id=ipd.inquiryId " +
            "LEFT JOIN inquirysparedetail isd on i.id=isd.inquiryId " +
            "LEFT JOIN legalperson lp on lp.id=i.legalPersonId")
    List<Inquirysupplierdetail> queryByInquirysupplierdetail(InquirySelectVo inquirySelectVo);

    @Select("select * from inquirytotal where requestForQuotationId=#{requestForQuotationId}")
    InquiryVo queryByrequestForQuotationId(String requestForQuotationId);

    @Update("update inquirytotal set inquiryStatus=#{inquiryStatus},updateName=#{updateName},updateTime=#{updateTime} where requestForQuotationId=#{requestForQuotationId}")
    void modifyState(InquiryVo inquiryVo1);

    void addInquiryTotal(InquiryTotal inquiryTotal);

    void addInquirySparePartDetail(List<Inquirysparedetail> inquirysparedetailList);

    void addInquirySupplierDetail(List<Inquirysupplierdetail> inquirysupplierdetailList);

    LegalPersonVo queryLegalPersonById(Integer legalPersonId);

    List<String> querySparePartByCodeList(List<String> codeList);

    List<String> querySupplierPartByCodeList(List<String> codeList1);

    List<SpareSupplier> querySpareSupplierByCodeList(List<String> codeList);

    List<SpareSupplier> querySupplierSpareByCodeList(List<String> codeList);


  /*  @Select("select * from factory where legalPlantCode=#{legalPlantCode}")
    List<FactoryVo> queryBylegalPlantCode(String legalPlantCode);
    List<String> queryByPlantCodes(List<String> plantCodeList);

    @Select("select LegalPersonCode from corporate where LegalPersonCode=#{LegalPersonCode}")
    List<String> queryByLegalPersonCode(String LegalPersonCode);
    List<String> queryByPersonCodes(List<String> personCodeList);

    @Insert("insert into factory (legalPersonCode,legalPlantCode,enabled,legalPlantDec,createName,createTime,updateName,updateTime) values" +
            "(#{legalPersonCode},#{legalPlantCode},#{enabled},#{legalPlantDec},#{createName},#{createTime},#{updateName},#{updateTime})")
    void add(FactoryVo factoryVo);
    void addList(List<FactoryVo> factoryVoList);

    @Update("update factory set enabled=#{enabled},updateName=#{updateName},updateTime=#{updateTime} where id=#{id}")
    void updateStatus(FactoryVo factoryVo1);

    @Update("update factory set enabled=#{enabled},legalPlantDec=#{legalPlantDec}," +
            "updateName=#{updateName},updateTime=#{updateTime} where legalPlantCode=#{legalPlantCode}")
    void update(FactoryVo factoryVo1);

    @Select("select * from factory where id=#{id}")
    FactoryVo queryById(Integer id);

    @Select("select * from corporate where userId=#{userId}")
    List<InquiryVo> queryCorporateByUserId(Integer userId);

    List<FactoryVo> queryDataExport(CorporateFactorySelectVo corporateFactorySelectVo);*/
}
